
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    // 一个对象，存储当前登录信息用户信息（token等数据）
    user: JSON.parse(window.localStorage.getItem('TOKEN_KEY')),
    userHistory: JSON.parse(window.localStorage.getItem('USER_HISTORY'))
    // refresh_token:null
  },
  mutations: {
    setUser (state, data) {
      state.user = data
      window.localStorage.setItem('TOKEN_KEY', JSON.stringify(state.user))
    },
    setHistory (state, data) {
      console.log(1)
      state.userHistory = data
      window.localStorage.setItem('USER_HISTORY', JSON.stringify(state.userHistory))
    }
  },
  actions: {
  },
  modules: {
  }
})
